﻿using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using System.Linq.Expressions;
using ASPItalia.ModelVirtualCasting.Common;
using ASPItalia.ModelVirtualCasting.ObjectModel;
using ASPItalia.ModelVirtualCasting.Parts;

namespace ASPItalia.ModelVirtualCasting.Fake
{
	[Export("CandidateRepository", typeof(ICandidateRepository))]
	[PartCreationPolicy(CreationPolicy.NonShared)]
	[RepositoryMetadata(Name = "CandidateRepository", IsFake = true)]
	public class CandidateRepository : BaseRepository<ICandidateRepository>, ICandidateRepository
	{
		protected List<Candidate> List = new List<Candidate>();

		public CandidateRepository()
		{
			Candidate candidate = null;

			candidate = new Candidate();
			candidate.NickName = "Ricky";
			candidate.FirstName = "Riccardo";
			candidate.LastName = "Golia";
			candidate.BirthDate = new DateTime(1971, 10, 21);
			candidate.CanBeNaked = false;
			candidate.EmailAddress = "riccardo@aspitalia.com";
			candidate.Gender = "M";
			candidate.NationalityCountry = new Country { CountryID = 1, CountryName = "Italia" };
			candidate.ResidenceCountry = new Country { CountryID = 1, CountryName = "Italia" };
			candidate.PhysicalProfile = new PhysicalProfile();
			candidate.PhysicalProfile.BodyHeight = 182;
			candidate.PhysicalProfile.BodySize = 48;
			candidate.PhysicalProfile.EyesColor = "Castani";
			candidate.PhysicalProfile.HairColor = "Castani";
			candidate.PhysicalProfile.Measurement = new Measurement { ChestMeasurement = 106, WaistMeasurement = 79, HipMeasurement = 84 };
			candidate.Multimedia = new List<Multimedia>();
			candidate.Multimedia.Add(new Image { FileName = "12345.jpg" });
			candidate.Multimedia.Add(new Image { FileName = "67890.jpg" });
			candidate.Multimedia.Add(new Video { FileName = "qwerty.avi" });

			this.List.Add(candidate);

			candidate = new Candidate();
			candidate.NickName = "Cradle";
			candidate.FirstName = "Marco";
			candidate.LastName = "De Sanctis";
			candidate.BirthDate = new DateTime(1977, 7, 10);
			candidate.CanBeNaked = false;
			candidate.EmailAddress = "crad@aspitalia.com";
			candidate.Gender = "M";
			candidate.NationalityCountry = new Country { CountryID = 1, CountryName = "Italia" };
			candidate.ResidenceCountry = new Country { CountryID = 3, CountryName = "Regno Unito" };
			candidate.PhysicalProfile = new PhysicalProfile();
			candidate.PhysicalProfile.BodyHeight = 178;
			candidate.PhysicalProfile.BodySize = 52;
			candidate.PhysicalProfile.EyesColor = "Verdi";
			candidate.PhysicalProfile.HairColor = "Castani";
			candidate.PhysicalProfile.Measurement = new Measurement { ChestMeasurement = 60, WaistMeasurement = 90, HipMeasurement = 90 };
			candidate.Multimedia = new List<Multimedia>();
			candidate.Multimedia.Add(new Image { FileName = "12330.jpg" });
			candidate.Multimedia.Add(new Image { FileName = "13616.jpg" });
			candidate.Multimedia.Add(new Video { FileName = "SomeMovie.avi" });

			this.List.Add(candidate);

			this.List.Add(new Candidate
			{
				NickName = "Jessica",
				FirstName = "Jessica",
				LastName = "Antoni",
				Gender = "F",
				BirthDate = new DateTime(1983, 2, 5),
				ResidenceCountry = new Country { CountryID = 1, CountryName = "Italia" }
			});

			this.List.Add(new Candidate
			{
				NickName = "Carla",
				FirstName = "Carla",
				LastName = "Fresi",
				Gender = "F",
				BirthDate = new DateTime(1979, 2, 11),
				ResidenceCountry = new Country { CountryID = 1, CountryName = "Italia" }
			});

			this.List.Add(new Candidate
			{
				NickName = "Killer",
				FirstName = "Antonio",
				LastName = "Rossi",
				Gender = "M",
				BirthDate = new DateTime(1983, 1, 5),
				ResidenceCountry = new Country { CountryID = 3, CountryName = "Regno Unito" }
			});

			this.List.Add(new Candidate
			{
				NickName = "Sandrina82",
				FirstName = "Sandra",
				LastName = "Sindoni",
				Gender = "F",
				BirthDate = new DateTime(1982, 9, 22),
				ResidenceCountry = new Country { CountryID = 1, CountryName = "Italia" }
			});
		}

		public void InsertOnSubmit(Candidate entity)
		{
		}

		public void Update(Candidate entity)
		{
		}

		public void DeleteOnSubmit(Candidate entity)
		{
		}

		public void SubmitChanges()
		{
		}

		public IQueryable<Candidate> GetAll()
		{
			return this.List.AsQueryable();
		}

		public IQueryable<Candidate> Where(Expression<Func<Candidate, bool>> predicate)
		{
			return this.List.AsQueryable().Where(predicate);
		}

		public long Count(Expression<Func<Candidate, bool>> predicate)
		{
			return this.Where(predicate).Count();
		}

		public Candidate GetByID(int id)
		{
			return this.Where(c => c.ID == id).Single();
		}

		public ICandidateRepository EnableLazyLoading()
		{
			return this;
		}

		public ICandidateRepository DisableLazyLoading()
		{
			return this;
		}

		public ICandidateRepository Include(string path)
		{
			return this;
		}


		public ICandidateRepository Include<TProperty>(Expression<Func<Candidate, TProperty>> path)
		{
			return this;
		}

		public ICandidateRepository CreateQuery()
		{
			return this;
		}

		public ICandidateRepository DoNotTrack()
		{
			return this;
		}
	}
}